const KEY_PREFIX = 'PINIA_STORE_'



export default function(context) {
	const {
		store
	} = context;

	const KEY = KEY_PREFIX + store.$id.toUpperCase();


	//存
	store.$subscribe((mutation, state) => {


		try {
			uni.setStorage({
				key: KEY,
				data: state
			})
		} catch {

		}

	})

	//读
	try {
		const localData = uni.getStorageSync(KEY)
		if (localData) store.$patch(localData)
	} catch {

	}



}